#!/bin/sh
STATIC_PATH=/config/ip/static
DYNAMIC_PATH=/tmp/ip/dynamic

case "$1" in
  start)
    mkdir -p $STATIC_PATH
    mkdir -p $DYNAMIC_PATH

    # Collect all of the interface names.
    # This variable may contain duplicates.
    # ipapply will unique-ify and run once for each interface.
    interfaces="$(ls -A $STATIC_PATH) $(ls -A $DYNAMIC_PATH)"
    if [ -n "$interfaces" -a "$interfaces" != " " ]; then
      ipapply $interfaces
    fi
    ;;
  stop)
    ;;
  restart)
    $0 stop; $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac
